home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / MISC.SWG / 0117_Saving Help Contexts.pas < prev    next >
Pascal/Delphi Source File  |  1995-03-03  |  4KB  |  152 lines

  1. {
  2.     A fragment to save a help context to disk/printer, in Turbo
  3. Vision 2.0:
  4.  
  5. In HelpFile.PAS:
  6. }
  7.  
  8. Uses ... , ... , Print;
  9.  
  10. Type
  11.  
  12.   TSetup = Record
  13.     HFIleName : String[80];
  14.     OutTxt,
  15.     Paper     : Word;
  16.   end;
  17.  
  18.   PHelpViewer = ^THelpViewer;
  19.   THelpViewer = object(TScroller)
  20.     HFile: PHelpFile;
  21.     Topic: PHelpTopic;
  22.     Selected: Integer;
  23.     constructor Init(var Bounds: TRect; AHScrollBar,
  24.       AVScrollBar: PScrollBar; AHelpFile: PHelpFile; Context: Word);
  25.     destructor Done; virtual;
  26.     procedure ChangeBounds(var Bounds: TRect); virtual;
  27.     procedure Draw; virtual;
  28.     function GetPalette: PPalette; virtual;
  29.     procedure HandleEvent(var Event: TEvent); virtual;
  30.     Procedure Print; {++++++ NEW +++++}
  31.   end;
  32.  
  33. Var
  34.   Setup       : TSetup;
  35.  
  36. {--------Procedure THelpViewer.Print--------}
  37.  
  38. procedure THelpViewer.Print;
  39. var
  40.   I      : Integer;
  41.   F      : Text;
  42.   Dialog : PDialog;
  43.   R      : TRect;
  44.   Control: PView;
  45.   Ctrl,
  46.   Modulo : Word;
  47. begin
  48.   R.Assign(00, 00, 35, 15);
  49.   Dialog := New(PDialog,  Init(R, 'Save Help Context'));
  50.   With Dialog^ do
  51.     begin
  52.       Options := Options or ofFramed or ofCentered;
  53.       Setup.HFileName := 'HelpCtx.txt';
  54.       R.Assign(3, 3, 32, 4);
  55.       Control := New(PInputLine, Init(R, 80));
  56.       Control^.Options := Control^.Options or ofFramed;
  57.       Dialog^.Insert(Control);
  58.  
  59.         R.Assign(29, 3, 32, 4);
  60.         Control := New(PHistory, Init(R, PInputline(Control), 3));
  61.         Dialog^.Insert(Control);
  62.  
  63.         R.Assign(3, 2, 20, 3);
  64.         Control := New(PLabel, Init(R, 'File Name:',Control));
  65.         Dialog^.Insert(Control);
  66.  
  67.       Setup.OutTxt := $0;
  68.       R.Assign(3, 6, 32, 7);
  69.       Control := New(PRadioButtons, Init(R,
  70.         NewSItem('Disk',
  71.         NewSItem('Printer', Nil))));
  72.       Control^.Options := Control^.Options or ofFramed;
  73.       Dialog^.Insert(Control);
  74.  
  75.         R.Assign(3, 5, 13, 6);
  76.         Control :=  New(PLabel, Init(R, 'Save to:', Control));
  77.         Dialog^.Insert(Control);
  78.  
  79.       Setup.Paper := $00;
  80.       R.Assign(3, 9, 32, 10);
  81.       Control := New(PRadioButtons, Init(R,
  82.         NewSItem('66 lines',
  83.         NewSItem('72 lines', Nil))));
  84.       Control^.Options := Control^.Options or ofFramed;
  85.       Dialog^.Insert(Control);
  86.  
  87.         R.Assign(3, 8, 21, 9);
  88.         Control := New(PLabel, Init(R, 'Paper:',Control));
  89.         Dialog^.Insert(Control);
  90.  
  91.       R.Assign(3, 12, 13, 14);
  92.       Control := New(PButton, Init(R, 'O~k~', cmOK, bfDefault));
  93.       Dialog^.Insert(Control);
  94.       R.Assign(21, 12, 31, 14);
  95.       Control := New(PButton, Init(R, '~C~ancel', cmCancel, bfNormal));
  96.       Dialog^.Insert(Control);
  97.  
  98.       Dialog^.SelectNext(False);
  99.     end;
  100.   Dialog^.SetData(Setup);
  101.   Ctrl := Application^.ExecView(Dialog);
  102.   If Ctrl <> cmCancel Then
  103.   Begin
  104.     Dialog^. GetData (Setup);
  105.     Case Setup.OutTxt of
  106.       $00 : Begin
  107.               If Setup.HFileName = '' then Setup.HFileName := 'HlpCtx.txt';
  108.               Assign(F, Setup.HFileName);
  109.               Rewrite(F);
  110.               For I := 1 to Topic^.NumLines do Writeln(F,Topic^.GetLine(I));
  111.               Close(F);
  112.             end;
  113.       $01 : begin
  114.               Case Setup.Paper of
  115.                 $00 : begin
  116.                         Modulo := 60;
  117.                         Write (Lst,Chr(27)+'C'+chr(66))
  118.                       end;
  119.                 $01 : begin
  120.                         Modulo := 66;
  121.                         Write (Lst,Chr(27)+'C'+chr(72))
  122.                       end;
  123.               end;
  124.               For I := 1 to Topic^.NumLines do
  125.                 begin
  126.                   Writeln(Lst,Topic^.GetLine(I));
  127.                   If I Mod Modulo = 0 then Write(Lst,#12);
  128.                 end;
  129.               Write(Lst,#12);
  130.             end
  131.     end;
  132.   end;
  133. end;
  134.  
  135. {--------Procedure THelpViewer.HandleEvent---------}
  136. ........ fragment
  137.           kbEnter:if Selected <= Topic^.GetNumCrossRefs then
  138.             begin
  139.               Topic^.GetCrossRef(Selected, KeyPoint, KeyLength, KeyRef);
  140.               SwitchToTopic(KeyRef);
  141.             end;
  142.           kbAltSpace:   +++ New +++
  143.             begin       +++ New +++
  144.               Print;    +++ New +++
  145.             end         +++ New +++
  146.         else
  147.           Exit;
  148.         end;
  149.         DrawView;
  150.         ClearEvent(Event);
  151.         .......... fragment
  152.